//
// (C) Copyright 2009 Irantha Suwandarathna (irantha@gmail.com)
// All rights reserved.
//

/* Copyright (c) 2001-2008, The HSQL Development Group
 * All rights reserved.
 *
 * Redistribution and use _in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions _in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer _in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the HSQL Development Group nor the names of its
 * contributors may be used to endorse or promote products derived from this
 * software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


using System;
using System.Collections.Generic;



namespace EffiProzDB
{

    /**
     * Defines and enumerates reserved and non-reserved SQL
     * keywords. <p>
     *
     * @author  Nitin Chauhan
     * @author  fredt@users
     * @since 1.7.2
     * @version 1.7.2
     */
    public class Token
    {

        public static Dictionary<string,int> commandSet;

        //

        public const string T_ASTERISK = "*";
        public const string T_COMMA = ",";
        public const string T_CLOSEBRACKET = ")";
        public const string T_EQUALS = "=";
        public const string T_DIVIDE = "/";
        public const string T_OPENBRACKET = "(";
        public const string T_SEMICOLON = ";";
        public const string T_MULTIPLY = "*";
        public const string T_PERCENT = "%";
        public const string T_PLUS = "+";
        public const string T_QUESTION = "?";


        // SQL 200n reserved tokens
        public const string T_ADD = "ADD";              //reserved
        public const string T_ALL = "ALL";              //reserved
        public const string T_ALLOCATE = "ALLOCATE";         //reserved
        public const string T_ALTER = "ALTER";            //reserved
        public const string T_AND = "AND";              //reserved
        public const string T_ANY = "ANY";              //reserved
        public const string T_ARE = "ARE";              //reserved
        public const string T_ARRAY = "ARRAY";            //reserved
        public const string T_AS = "AS";               //reserved
        public const string T_ASENSITIVE = "ASENSITIVE";       //reserved
        public const string T_ASYMMETRIC = "ASYMMETRIC";       //reserved
        public const string T_AT = "AT";               //reserved
        public const string T_ATOMIC = "ATOMIC";           //reserved
        public const string T_AUTHORIZATION = "AUTHORIZATION";    //reserved
        public const string T_BEGIN = "BEGIN";            //reserved
        public const string T_BETWEEN = "BETWEEN";
        public const string T_BIGINT = "BIGINT";           //reserved
        public const string T_BINARY = "BINARY";           //reserved
        public const string T_BLOB = "BLOB";             //reserved
        public const string T_bool = "bool";          //reserved
        public const string T_BOTH = "BOTH";
        public const string T_BY = "BY";               //reserved
        public const string T_CALL = "CALL";             //reserved
        public const string T_CALLED = "CALLED";           //reserved
        public const string T_CASCADED = "CASCADED";         //reserved
        public const string T_CASE = "CASE";             //reserved
        public const string T_CAST = "CAST";             //reserved
        public const string T_CHAR = "CHAR";             //reserved
        public const string T_CHARACTER = "CHARACTER";        //reserved
        public const string T_CHECK = "CHECK";            //reserved
        public const string T_CLOB = "CLOB";             //reserved
        public const string T_CLOSE = "CLOSE";            //reserved
        public const string T_COLLATE = "COLLATE";          //reserved
        public const string T_COLUMN = "COLUMN";           //reserved
        public const string T_COMMIT = "COMMIT";           //reserved
        public const string T_CONDITION = "CONDIITON";        //reserved
        public const string T_CONNECT = "CONNECT";          //reserved
        public const string T_CONSTRAINT = "CONSTRAINT";       //reserved
        public const string T_CONTINUE = "CONTINUE";         //reserved
        public const string T_CORRESPONDING = "CORRESPONDING";    //reserved
        public const string T_CREATE = "CREATE";           //reserved
        public const string T_CROSS = "CROSS";            //reserved
        public const string T_CUBE = "CUBE";             //reserved
        public const string T_CURRENT = "CURRENT";          //reserved
        public const string T_CURRENT_DATE = "CURRENT_DATE";     //reserved
        public const string T_CURRENT_DEFAULT_TRANS_GROUP =
            "CURRENT_DEFAULT_TRANSFORM_GROUP";                                         //reserved
        public const string T_CURRENT_PATH = "CURRENT_PATH";           //reserved
        public const string T_CURRENT_ROLE = "CURRENT_ROLE";           //reserved
        public const string T_CURRENT_TIME = "CURRENT_TIME";           //reserved
        public const string T_CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP";      //reserved
        public const string T_CURRENT_TRANS_GROUP_FOR_TYPE =
            "CURRENT_TRANSFORM_GROUP_FOR_TYPE";                                        //reserved
        public const string T_CURRENT_USER = "CURRENT_USER";                 //reserved
        public const string T_CURSOR = "CURSOR";                       //reserved
        public const string T_CYCLE = "CYCLE";                        //reserved
        public const string T_DATE = "DATE";                         //reserved
        public const string T_DAY = "DAY";                          //reserved
        public const string T_DEALLOCATE = "DEALLOCATE";                   //reserved
        public const string T_DEC = "DEC";                          //reserved
        public const string T_DECIMAL = "DECIMAL";                      //reserved
        public const string T_DECLARE = "DECLARE";                      //reserved
        public const string T_DEFAULT = "DEFAULT";                      //reserved
        public const string T_DELETE = "DELETE";                       //reserved
        public const string T_DEREF = "DEREF";                        //reserved
        public const string T_DESCRIBE = "DESCRIBE";                     //reserved
        public const string T_DETERMINISTIC = "DETERMINISTIC";                //reserved
        public const string T_DISCONNECT = "DISCONNECT";                   //reserved
        public const string T_DISTINCT = "DISTINCT";                     //reserved
        public const string T_DO = "DO";                           //reserved
        public const string T_DOUBLE = "DOUBLE";                       //reserved
        public const string T_DOW = "DAYOFWEEK";                    //reserved
        public const string T_DROP = "DROP";                         //reserved
        public const string T_DYNAMIC = "DYNAMIC";                      //reserved
        public const string T_EACH = "EACH";                         //reserved
        public const string T_ELEMENT = "ELEMENT";                      //reserved
        public const string T_ELSE = "ELSE";                         //reserved
        public const string T_ELSEIF = "ELSEIF";                       //reserved
        public const string T_END = "END";                          //reserved
        public const string T_ESCAPE = "ESCAPE";                       //reserved
        public const string T_EXCEPT = "EXCEPT";                       //reserved
        public const string T_EXEC = "EXEC";                         //reserved
        public const string T_EXECUTE = "EXECUTE";                      //reserved
        public const string T_EXISTS = "EXISTS";                       //reserved
        public const string T_EXIT = "EXIT";                         //reserved
        public const string T_EXTERNAL = "EXTERNAL";                     //reserved
        public const string T_FALSE = "FALSE";                        //reserved
        public const string T_FETCH = "FETCH";                        //reserved
        public const string T_FILTER = "FILTER";                       //reserved
        public const string T_FLOAT = "FLOAT";                        //reserved
        public const string T_FOR = "FOR";                          //reserved
        public const string T_FOREIGN = "FOREIGN";                      //reserved
        public const string T_FREE = "FREE";                         //reserved
        public const string T_FROM = "FROM";                         //reserved
        public const string T_FULL = "FULL";                         //reserved
        public const string T_FUNCTION = "FUNCTION";                     //reserved
        public const string T_GET = "GET";                          //reserved
        public const string T_GLOBAL = "GLOBAL";                       //reserved
        public const string T_GRANT = "GRANT";                        //reserved
        public const string T_GROUP = "GROUP";                        //reserved
        public const string T_GROUPING = "GROUPING";                     //reserved
        public const string T_HANDLER = "HANDLER";                      //reserved
        public const string T_HAVING = "HAVING";                       //reserved
        public const string T_HEADER = "HEADER";                       //reserved
        public const string T_HOLD = "HOLD";                         //reserved
        public const string T_HOUR = "HOUR";                         //reserved
        public const string T_IDENTITY = "IDENTITY";                     //reserved
        public const string T_IF = "IF";                           //reserved
        public const string T_IMMEDIATE = "IMMEDIATE";                    //reserved
        public const string T_IN = "IN";                           //reserved
        public const string T_INDICATOR = "INDICATOR";                    //reserved
        public const string T_INNER = "INNER";                        //reserved
        public const string T_INOUT = "INOUT";                        //reserved
        public const string T_INPUT = "INPUT";                        //reserved
        public const string T_INSENSITIVE = "INSENSITIVE";                  //reserved
        public const string T_INSERT = "INSERT";                       //reserved
        public const string T_INT = "INT";                          //reserved
        public const string T_INTEGER = "INTEGER";                      //reserved
        public const string T_INTERSECT = "INTERSECT";                    //reserved
        public const string T_INTERVAL = "INTERVAL";                     //reserved
        public const string T_INTO = "INTO";                         //reserved
        public const string T_IS = "IS";                           //reserved
        public const string T_ITERATE = "ITERATE";                      //reserved
        public const string T_JOIN = "JOIN";                         //reserved
        public const string T_LANGUAGE = "LANGUAGE";                     //reserved
        public const string T_LARGE = "LARGE";                        //reserved
        public const string T_LATERAL = "LATERAL";                      //reserved
        public const string T_LEADING = "LEADING";                      //reserved
        public const string T_LEAVE = "LEAVE";                        //reserved
        public const string T_LEFT = "LEFT";                         //reserved
        public const string T_LIKE = "LIKE";                         //reserved
        public const string T_LOCAL = "LOCAL";                        //reserved
        public const string T_LOCALTIME = "LOCALTIME";                    //reserved
        public const string T_LOCALTIMESTAMP = "LOCALTIMESTAMP";               //reserved
        public const string T_LOOP = "LOOP";                         //reserved
        public const string T_MATCH = "MATCH";                        //reserved
        public const string T_MEMBER = "MEMBER";                       //reserved
        public const string T_METHOD = "METHOD";                       //reserved
        public const string T_MINUTE = "MINUTE";                       //reserved
        public const string T_MODIFIES = "MODIFIES";                     //reserved
        public const string T_MODULE = "MODULE";                       //reserved
        public const string T_MONTH = "MONTH";                        //reserved
        public const string T_MULTISET = "MULTISET";                     //reserved
        public const string T_NATIONAL = "NATIONAL";                     //reserved
        public const string T_NATURAL = "NAUTRAL";                      //reserved
        public const string T_NCHAR = "NCHAR";                        //reserved
        public const string T_NCLOB = "NCLOB";                        //reserved
        const string T_NEW = "NEW";                          //reserved
        public const string T_NEXT = "NEXT";                         //reserved
        public const string T_NO = "NO";                           //reserved
        public const string T_NONE = "NONE";                         //reserved
        public const string T_NOT = "NOT";                          //reserved
        public const string T_NULL = "NULL";                         //reserved
        public const string T_NUMERIC = "NUMERIC";                      //reserved
        public const string T_OF = "OF";                           //reserved
        public const string T_OLD = "OLD";                          //reserved
        public const string T_ON = "ON";                           //reserved
        public const string T_ONLY = "ONLY";                         //reserved
        public const string T_OPEN = "OPEN";                         //reserved
        public const string T_OR = "OR";                           //reserved
        public const string T_ORDER = "ORDER";                        //reserved
        public const string T_OUT = "OUT";                          //reserved
        public const string T_OUTER = "OUTER";                        //reserved
        public const string T_OUTPUT = "OUTPUT";                       //reserved
        public const string T_OVER = "OVER";                         //reserved
        public const string T_OVERLAPS = "OVERLAPS";                     //reserved
        public const string T_PARAMETER = "PARAMETER";                    //reserved
        public const string T_PARTITION = "PARTITION";                    //reserved
        public const string T_PRECISION = "PRECISION";                    //reserved
        public const string T_PREPARE = "PREPARE";                      //reserved
        public const string T_PRIMARY = "PRIMARY";                      //reserved
        public const string T_PROCEDURE = "PROCEDURE";                    //reserved
        public const string T_RANGE = "RANGE";                        //reserved
        public const string T_READS = "READS";                        //reserved
        public const string T_REAL = "REAL";                         //reserved
        public const string T_RECURSIVE = "RECURSIVE";                    //reserved
        public const string T_REF = "REF";                          //reserved
        public const string T_REFERENCES = "REFERENCES";                   //reserved
        public const string T_REFERENCING = "REFERENCING";                  //reserved
        public const string T_RELEASE = "RELEASE";                      //reserved
        public const string T_REPEAT = "REPEAT";                       //reserved
        public const string T_RESIGNAL = "RESIGNAL";                     //reserved
        public const string T_RESULT = "RESULT";                       //reserved
        public const string T_RETURN = "RETURN";                       //reserved
        public const string T_RETURNS = "RETURNS";                      //reserved
        public const string T_REVOKE = "REVOKE";                       //reserved
        public const string T_RIGHT = "RIGHT";                        //reserved
        public const string T_ROLLBACK = "ROLLBACK";                     //reserved
        public const string T_ROLLUP = "ROLLUP";                       //reserved
        public const string T_ROW = "ROW";                          //reserved
        public const string T_ROWS = "ROWS";                         //reserved
        public const string T_SAVEPOINT = "SAVEPOINT";                    //reserved
        public const string T_SCOPE = "SCOPE";                        //reserved
        public const string T_SCROLL = "SCROLL";                       //reserved
        public const string T_SECOND = "SECOND";                       //reserved
        public const string T_SEARCH = "SEARCH";                       //reserved
        public const string T_SELECT = "SELECT";                       //reserved
        public const string T_SENSITIVE = "SENSITIVE";                    //reserved
        public const string T_SESSION_USER = "SESSION_USER";                 //reserved
        public const string T_SET = "SET";                          //reserved
        public const string T_SIGNAL = "SIGNAL";                       //reserved
        public const string T_SIMILAR = "SIMILAR";                      //reserved
        public const string T_SMALLINT = "SMALLINT";                     //reserved
        public const string T_SOME = "SOME";                         //reserved
        public const string T_SPECIFIC = "SPECIFIC";                     //reserved
        public const string T_SPECIFICTYPE = "SPECIFICTYPE";                 //reserved
        public const string T_SQL = "SQL";                          //reserved
        public const string T_SQLEXCEPTION = "SQLEXCEPTION";                 //reserved
        public const string T_SQLSTATE = "SQLSTATE";                     //reserved
        public const string T_SQLWARNING = "SQLWARNING";                   //reserved
        public const string T_START = "START";                        //reserved
        public const string T_STATIC = "STATIC";                       //reserved
        public const string T_SUBMULTISET = "SUBMULTISET";                  //reserved
        public const string T_SYMMETRIC = "SYMMETRIC";                    //reserved
        public const string T_SYSTEM = "SYSTEM";                       //reserved
        public const string T_SYSTEM_USER = "SYSTEM_USER";                  //reserved
        public const string T_TABLE = "TABLE";                        //reserved
        public const string T_TABLESAMPLE = "TABLESAMPLE";                  //reserved
        public const string T_THEN = "THEN";                         //reserved
        public const string T_TIME = "TIME";                         //reserved
        public const string T_TIMESTAMP = "TIMESTAMP";                    //reserved
        public const string T_TIMEZONE_HOUR = "TIMEZONE_HOUR";                //reserved
        public const string T_TIMEZONE_MINUTE = "TIMEZONE_MINUTE";              //reserved
        public const string T_TO = "TO";                           //reserved
        public const string T_TRAILING = "TRAILING";                     //reserved
        public const string T_TRANSLATION = "TRANSLATION";                  //reserved
        public const string T_TREAT = "TREAT";                        //reserved
        public const string T_TRIGGER = "TRIGGER";                      //reserved
        public const string T_TRUE = "TRUE";                         //reserved
        public const string T_UNDO = "UNDO";                         //reserved
        public const string T_UNION = "UNION";                        //reserved
        public const string T_UNIQUE = "UNIQUE";                       //reserved
        public const string T_UNKNOWN = "UNKNOWN";                      //reserved
        public const string T_UNNEST = "UNNEST";                       //reserved
        public const string T_UNTIL = "UNTIL";                        //reserved
        public const string T_UPDATE = "UPDATE";                       //reserved
        public const string T_USER = "USER";                         //reserved
        public const string T_USING = "USING";                        //reserved
        public const string T_VALUE = "VALUE";                        //reserved
        public const string T_VALUES = "VALUES";                       //reserved
        public const string T_VARCHAR = "VARCHAR";                      //reserved
        public const string T_VARYING = "VARYING";                      //reserved
        public const string T_WHEN = "WHEN";                         //reserved
        public const string T_WHENEVER = "WHENEVER";                     //reserved
        public const string T_WHERE = "WHERE";                        //reserved
        public const string T_WHILE = "WHILE";                        //reserved
        public const string T_WINDOW = "WINDOW";                       //reserved
        public const string T_WITH = "WITH";                         //reserved
        public const string T_WITHIN = "WITHIN";                       //reserved
        public const string T_WITHOUT = "WITHOUT";                      //reserved
        public const string T_YEAR = "YEAR";                         //reserved

        // other tokens
        public const string T_ALWAYS = "ALWAYS";
        public const string T_ACTION = "ACTION";
        public const string T_ADMIN = "ADMIN";
        public const string T_AFTER = "AFTER";
        public const string T_ALIAS = "ALIAS";
        public const string T_ASC = "ASC";
        public const string T_AUTOCOMMIT = "AUTOCOMMIT";
        public const string T_AVG = "AVG";
        public const string T_BACKUP = "BACKUP";
        public const string T_BEFORE = "BEFORE";
        public const string T_CACHED = "CACHED";
        public const string T_CASCADE = "CASCADE";
        public const string T_CASEWHEN = "CASEWHEN";
        public const string T_CHECKPOINT = "CHECKPOINT";
        public const string T_CLASS = "CLASS";
        public const string T_COALESCE = "COALESCE";
        public const string T_COLLATION = "COLLATION";
        public const string T_COMPACT = "COMPACT";
        public const string T_COMPRESSED = "COMPRESSED";
        public const string T_CONVERT = "CONVERT";
        public const string T_COUNT = "COUNT";
        public const string T_DATABASE = "DATABASE";
        public const string T_DEFRAG = "DEFRAG";
        public const string T_DESC = "DESC";
        public const string T_EVERY = "EVERY";
        public const string T_EXPLAIN = "EXPLAIN";
        public const string T_EXTRACT = "EXTRACT";
        public const string T_GENERATED = "GENERATED";
        public const string T_IFNULL = "IFNULL";
        public const string T_IGNORECASE = "IGNORECASE";
        public const string T_IMMEDIATELY = "IMMEDIATELY";
        public const string T_INCREMENT = "INCREMENT";
        public const string T_INDEX = "INDEX";
        public const string T_INITIAL = "INITIAL";
        public const string T_KEY = "KEY";
        public const string T_LIMIT = "LIMIT";
        public const string T_LOGSIZE = "LOGSIZE";
        public const string T_MAX = "MAX";
        public const string T_MAXROWS = "MAXROWS";
        public const string T_MEMORY = "MEMORY";
        public const string T_MERGE = "MERGE";
        public const string T_MIN = "MIN";
        public const string T_MINUS = "MINUS";
        public const string T_NOW = "NOW";
        public const string T_NOWAIT = "NOWAIT";
        public const string T_NULLIF = "NULLIF";
        public const string T_NVL = "NVL";
        public const string T_OFFSET = "OFFSET";
        public const string T_PASSWORD = "PASSWORD";
        public const string T_SCHEMA = "SCHEMA";
        public const string T_PLAN = "PLAN";
        public const string T_PRESERVE = "PRESERVE";
        public const string T_PRIVILEGES = "PRIVILEGES";
        public const string T_POSITION = "POSITION";
        public const string T_PROPERTY = "PROPERTY";
        public const string T_PUBLIC = "PUBLIC";
        public const string T_QUEUE = "QUEUE";
        public const string T_READONLY = "READONLY";
        public const string T_REFERENTIAL_INTEGRITY = "REFERENTIAL_INTEGRITY";
        public const string T_RENAME = "RENAME";
        public const string T_RESTART = "RESTART";
        public const string T_RESTRICT = "RESTRICT";
        public const string T_ROLE = "ROLE";
        public const string T_SCRIPT = "SCRIPT";
        public const string T_SCRIPTFORMAT = "SCRIPTFORMAT";
        public const string T_SEQUENCE = "SEQUENCE";
        public const string T_SHUTDOWN = "SHUTDOWN";
        public const string T_SOURCE = "SOURCE";
        public const string T_STDDEV_POP = "STDDEV_POP";
        public const string T_STDDEV_SAMP = "STDDEV_SAMP";
        public const string T_SUBSTRING = "SUBSTRING";
        public const string T_SUM = "SUM";
        public const string T_SYSDATE = "SYSDATE";
        public const string T_TEMP = "TEMP";
        public const string T_TEMPORARY = "TEMPORARY";
        public const string T_TEXT = "TEXT";
        public const string T_TODAY = "TODAY";
        public const string T_TOP = "TOP";
        public const string T_TRIM = "TRIM";
        public const string T_VAR_POP = "VAR_POP";
        public const string T_VAR_SAMP = "VAR_SAMP";
        public const string T_VIEW = "VIEW";
        public const string T_WORK = "WORK";
        public const string T_WRITE_DELAY = "WRITE_DELAY";
        public const string T_OFF = "OFF";

        // SQL 200n token values
        public const int ADD = 1;
        public const int ALL = 2;
        public const int ALLOCATE = 3;
        public const int ALTER = 4;
        public const int AND = 5;
        public const int ANY = 6;
        public const int ARE = 7;
        public const int ARRAY = 8;
        public const int AS = 9;
        public const int ASENSITIVE = 10;
        public const int ASYMMETRIC = 11;
        public const int AT = 12;
        public const int ATOMIC = 13;
        public const int AUTHORIZATION = 14;
        public const int BEGIN = 15;
        public const int BETWEEN = 16;
        public const int BIGINT = 17;
        public const int BINARY = 18;
        public const int BLOB = 19;
        public const int boolean = 20;
        public const int BOTH = 21;
        public const int BY = 22;
        public  const int CALL = 23;
        public const int CALLED = 24;
        public const int CASCADED = 25;
        public const int CASE = 26;
        public const int CAST = 27;
        public const int CHAR = 28;
        public const int CHARACTER = 29;
        public const int CHECK = 30;
        public const int CLOB = 31;
        public const int CLOSE = 32;
        public const int COLLATE = 33;
        public const int COLUMN = 34;
        public const int COMMIT = 35;
        public const int CONDITION = 36;
        public const int CONNECT = 37;
        public const int CONSTRAINT = 38;
        public const int CONTINUE = 39;
        public const int CORRESPONDING = 40;
        public const int CREATE = 41;
        public const int CROSS = 42;
        public const int CUBE = 43;
        public const int CURRENT = 44;
        public const int CURRENT_DATE = 45;
        public const int CURRENT_DEFAULT_TRANSFORM_GRO = 46;
        public const int CURRENT_PATH = 47;
        public const int CURRENT_ROLE = 48;
        public const int CURRENT_TIME = 49;
        public const int CURRENT_TIMESTAMP = 50;
        public const int CURRENT_TRANSFORM_GROUP_FOR_T = 51;
        public const int CURRENT_USER = 52;
        public const int CURSOR = 53;
        public const int CYCLE = 54;
        public const int DATE = 55;
        public const int DAY = 56;
        public const int DEALLOCATE = 57;
        public const int DEC = 58;
        public const int DECIMAL = 59;
        public const int DECLARE = 60;
        public const int DEFAULT = 61;
        public const int DELETE = 62;
        public const int DEREF = 63;
        public const int DESCRIBE = 64;
        public const int DETERMINISTIC = 65;
        public const int DISCONNECT = 66;
        public const int DISTINCT = 67;
        public const int DO = 68;
        public const int DOUBLE = 69;
        public const int DROP = 70;
        public const int DYNAMIC = 71;
        public const int EACH = 72;
        public const int ELEMENT = 73;
        public const int ELSE = 74;
        public const int ELSEIF = 75;
        public const int END = 76;
        public const int ESCAPE = 77;
        public const int EXCEPT = 78;
        public const int EXEC = 79;
        public const int EXECUTE = 80;
        public const int EXISTS = 81;
        public const int EXIT = 82;
        public const int EXTERNAL = 83;
        public const int FALSE = 84;
        public const int FETCH = 85;
        public const int FILTER = 86;
        public const int FLOAT = 87;
        public const int FOR = 88;
        public const int FOREIGN = 89;
        public const int FREE = 90;
        public const int FROM = 91;
        public const int FULL = 92;
        public const int FUNCTION = 93;
        public const int GET = 94;
        public const int GLOBAL = 95;
        public const int GRANT = 96;
        public const int GROUP = 97;
        public const int GROUPING = 98;
        public const int HANDLER = 99;
        public const int HAVING = 100;
        public const int HOLD = 101;
        public const int HOUR = 102;
        public const int IDENTITY = 103;
        public const int IF = 104;
        public const int IMMEDIATE = 105;
        public const int IN = 106;
        public const int INDICATOR = 107;
        public const int INNER = 108;
        public const int INOUT = 109;
        public const int INPUT = 110;
        public const int INSENSITIVE = 111;
        public const int INSERT = 112;
        public const int INT = 113;
        public const int INTEGER = 114;
        public const int INTERSECT = 115;
        public const int INTERVAL = 116;
        public const int INTO = 117;
        public const int IS = 118;
        public const int ITERATE = 119;
        public const int JOIN = 120;
        public const int LANGUAGE = 121;
        public const int LARGE = 122;
        public const int LATERAL = 123;
        public const int LEADING = 124;
        public const int LEAVE = 125;
        public const int LEFT = 126;
        public const int LIKE = 127;
        public const int LOCAL = 128;
        public const int LOCALTIME = 129;
        public const int LOCALTIMESTAMP = 130;
        public const int LOOP = 131;
        public const int MATCH = 132;
        public const int MEMBER = 133;
        public const int MERGE = 134;
        public const int METHOD = 135;
        public const int MINUTE = 136;
        public const int MODIFIES = 137;
        public const int MODULE = 138;
        public const int MONTH = 139;
        public const int MULTISET = 140;
        public const int NATIONAL = 141;
        public const int NATURAL = 142;
        public const int NCHAR = 143;
        public const int NCLOB = 144;
        public const int NEW = 145;
        public const int NO = 146;
        public const int NONE = 147;
        public const int NOT = 148;
        public const int NULL = 149;
        public const int NUMERIC = 150;
        public const int OF = 151;
        public const int OLD = 152;
        public const int ON = 153;
        public const int ONLY = 154;
        public const int OPEN = 155;
        public const int OR = 156;
        public const int ORDER = 157;
        public const int OUT = 158;
        public const int OUTER = 159;
        public const int OUTPUT = 160;
        public const int OVER = 161;
        public const int OVERLAPS = 162;
        public const int PARAMETER = 163;
        public const int PARTITION = 164;
        public const int PRECISION = 165;
        public const int PREPARE = 166;
        public const int PRIMARY = 167;
        public const int PROCEDURE = 168;
        public const int RANGE = 169;
        public const int READS = 170;
        public const int REAL = 171;
        public const int RECURSIVE = 172;
        public const int REF = 173;
        public const int REFERENCES = 174;
        public const int REFERENCING = 175;
        public const int RELEASE = 176;
        public const int REPEAT = 177;
        public const int RESIGNAL = 178;
        public const int RESULT = 179;
        public const int RETURN = 180;
        public const int RETURNS = 181;
        public const int REVOKE = 182;
        public const int RIGHT = 183;
        public const int ROLLBACK = 184;
        public const int ROLLUP = 185;
        public const int ROW = 186;
        public const int ROWS = 187;
        public const int SAVEPOINT = 188;
        public const int SCOPE = 189;
        public const int SCROLL = 190;
        public const int SEARCH = 191;
        public const int SECOND = 192;
        public const int SELECT = 193;
        public const int SENSITIVE = 194;
        public const int SESSION_USER = 195;
        public const int SET = 196;
        public const int SIGNAL = 197;
        public const int SIMILAR = 198;
        public const int SMALLINT = 199;
        public const int SOME = 200;
        public const int SPECIFIC = 201;
        public const int SPECIFICTYPE = 202;
        public const int SQL = 203;
        public const int SQLEXCEPTION = 204;
        public const int SQLSTATE = 205;
        public const int SQLWARNING = 206;
        public const int START = 207;
        public const int STATIC = 208;
        public const int SUBMULTISET = 209;
        public const int SYMMETRIC = 210;
        public const int SYSTEM = 211;
        public const int SYSTEM_USER = 212;
        public const int TABLE = 213;
        public const int TABLESAMPLE = 214;
        public const int THEN = 215;
        public const int TIME = 216;
        public const int TIMESTAMP = 217;
        public const int TIMEZONE_HOUR = 218;
        public const int TIMEZONE_MINUTE = 219;
        public const int TO = 220;
        public const int TRAILING = 221;
        public const int TRANSLATION = 222;
        public const int TREAT = 223;
        public const int TRIGGER = 224;
        public const int TRUE = 225;
        public const int UNDO = 226;
        public const int UNION = 227;
        public const int UNIQUE = 228;
        public const int UNKNOWN = 229;
        public const int UNNEST = 220;
        public const int UNTIL = 221;
        public const int UPDATE = 222;
        public const int USER = 223;
        public const int USING = 224;
        public const int VALUE = 225;
        public const int VALUES = 226;
        public const int VARCHAR = 227;
        public const int VARYING = 228;
        public const int WHEN = 229;
        public const int WHENEVER = 230;
        public const int WHERE = 231;
        public const int WHILE = 232;
        public const int WINDOW = 233;
        public const int WITH = 234;
        public const int WITHIN = 235;
        public const int WITHOUT = 236;
        public const int YEAR = 237;

        // other token values used as switch cases
        public const int UNKNOWNTOKEN = -1;
        public const int ALIAS = 300;
        public const int AUTOCOMMIT = 301;
        public const int CACHED = 302;
        public const int CHECKPOINT = 303;
        public const int EXPLAIN = 304;
        public const int IGNORECASE = 305;
        public const int INDEX = 306;
        public const int LOGSIZE = 307;
        public const int MATCHED = 308;
        public const int MAXROWS = 309;
        public const int MEMORY = 310;
        public const int MINUS = 311;
        public const int NEXT = 312;
        public const int OPENBRACKET = 313;
        public const int PASSWORD = 314;
        public const int PLAN = 315;
        public const int PROPERTY = 316;
        public const int READONLY = 317;
        public const int REFERENTIAL_INTEGRITY = 318;
        public const int RENAME = 319;
        public const int RESTART = 320;
        public const int SCRIPT = 321;
        public const int SCRIPTFORMAT = 322;
        public const int SEMICOLON = 323;
        public const int SEQUENCE = 324;
        public const int SHUTDOWN = 325;
        public const int SOURCE = 326;
        public const int TEMP = 327;
        public const int TEXT = 328;
        public const int VIEW = 329;
        public const int WRITE_DELAY = 330;

        // added stuff
        public const int VAR_POP = 330;
        public const int VAR_SAMP = 331;
        public const int STDDEV_POP = 332;
        public const int STDDEV_SAMP = 333;
        public const int DEFRAG = 334;
        public const int INCREMENT = 335;
        public const int TOCHAR = 336;
        public const int DATABASE = 337;
        public const int SCHEMA = 338;
        public const int ROLE = 339;
        public const int DOW = 340;
        public const int INITIAL = 341;

      

        /**
         * Retrieves a new map from set of string tokens to numeric tokens for
         * commonly encountered database command token occurences.
         *
         * @return a new map for the database command token set
         */
        private static Dictionary<string, int> newCommandSet()
        {

            Dictionary<string, int> commandSet;

            commandSet = new Dictionary<string, int>(67);

            commandSet.Add(T_ADD, ADD);
            commandSet.Add(T_ALIAS, ALIAS);
            commandSet.Add(T_ALTER, ALTER);
            commandSet.Add(T_AUTOCOMMIT, AUTOCOMMIT);
            commandSet.Add(T_CACHED, CACHED);
            commandSet.Add(T_CALL, CALL);
            commandSet.Add(T_CHECK, CHECK);
            commandSet.Add(T_CHECKPOINT, CHECKPOINT);
            commandSet.Add(T_COLUMN, COLUMN);
            commandSet.Add(T_COMMIT, COMMIT);
            commandSet.Add(T_CONNECT, CONNECT);
            commandSet.Add(T_CONSTRAINT, CONSTRAINT);
            commandSet.Add(T_CREATE, CREATE);
            commandSet.Add(T_DATABASE, DATABASE);
            commandSet.Add(T_DELETE, DELETE);
            commandSet.Add(T_DEFRAG, DEFRAG);
            commandSet.Add(T_DISCONNECT, DISCONNECT);
            commandSet.Add(T_DROP, DROP);
            commandSet.Add(T_EXCEPT, EXCEPT);
            commandSet.Add(T_EXPLAIN, EXPLAIN);
            commandSet.Add(T_FOREIGN, FOREIGN);
            commandSet.Add(T_GRANT, GRANT);
            commandSet.Add(T_IGNORECASE, IGNORECASE);
            commandSet.Add(T_INCREMENT, INCREMENT);
            commandSet.Add(T_INDEX, INDEX);
            commandSet.Add(T_INITIAL, INITIAL);
            commandSet.Add(T_INSERT, INSERT);
            commandSet.Add(T_INTERSECT, INTERSECT);
            commandSet.Add(T_LOGSIZE, LOGSIZE);
            commandSet.Add(T_MAXROWS, MAXROWS);
            commandSet.Add(T_MEMORY, MEMORY);
            commandSet.Add(T_MINUS, MINUS);
            commandSet.Add(T_NEXT, NEXT);
            commandSet.Add(T_NOT, NOT);
            commandSet.Add(T_OPENBRACKET, OPENBRACKET);
            commandSet.Add(T_PASSWORD, PASSWORD);
            commandSet.Add(T_PLAN, PLAN);
            commandSet.Add(T_PRIMARY, PRIMARY);
            commandSet.Add(T_PROPERTY, PROPERTY);
            commandSet.Add(T_READONLY, READONLY);
            commandSet.Add(T_REFERENTIAL_INTEGRITY, REFERENTIAL_INTEGRITY);
            commandSet.Add(T_RELEASE, RELEASE);
            commandSet.Add(T_RENAME, RENAME);
            commandSet.Add(T_RESTART, RESTART);
            commandSet.Add(T_REVOKE, REVOKE);
            commandSet.Add(T_ROLE, ROLE);
            commandSet.Add(T_ROLLBACK, ROLLBACK);
            commandSet.Add(T_SAVEPOINT, SAVEPOINT);
            commandSet.Add(T_SCRIPT, SCRIPT);
            commandSet.Add(T_SCRIPTFORMAT, SCRIPTFORMAT);
            commandSet.Add(T_SELECT, SELECT);
            commandSet.Add(T_SEMICOLON, SEMICOLON);
            commandSet.Add(T_SEQUENCE, SEQUENCE);
            commandSet.Add(T_SET, SET);
            commandSet.Add(T_SHUTDOWN, SHUTDOWN);
            commandSet.Add(T_SOURCE, SOURCE);
            commandSet.Add(T_TABLE, TABLE);
            commandSet.Add(T_TEMP, TEMP);
            commandSet.Add(T_TEXT, TEXT);
            commandSet.Add(T_TRIGGER, TRIGGER);
            commandSet.Add(T_UNIQUE, UNIQUE);
            commandSet.Add(T_UPDATE, UPDATE);
            commandSet.Add(T_UNION, UNION);
            commandSet.Add(T_USER, USER);
            commandSet.Add(T_VALUES, VALUES);
            commandSet.Add(T_VIEW, VIEW);
            commandSet.Add(T_WRITE_DELAY, WRITE_DELAY);
            commandSet.Add(T_SCHEMA, SCHEMA);

            return commandSet;
        }

        public static int get(string token)
        {
            int cmd = -1;
            if (!commandSet.TryGetValue(token, out cmd))
                return -1;
            return cmd;
        }

        public static HashSet<string> keywords;    

        static Token()
        {

            commandSet = newCommandSet();

            // literals not allowed as table / column names
            keywords = new HashSet<string>();

            // fredt - if we add MONTH, DAY, YEAR etc. MONTH(), DAY() et al will no longer work
            // following tokens are values

            /* "FALSE",*/
            /* "TRUE",*/
            /* "NULL", */

            /** @todo perhaps rename LEFT() */

            // following token is excluded to allow LEFT() function to work

            /* "LEFT" ,*/
            String[] keyword = {
            Token.T_AS, Token.T_AND, Token.T_ALL, Token.T_ANY, Token.T_AVG,
            Token.T_BY, Token.T_BETWEEN, Token.T_BOTH, Token.T_CALL,
            Token.T_CASE, Token.T_CASEWHEN, Token.T_CAST, Token.T_CONVERT,
            Token.T_COUNT, Token.T_COALESCE, Token.T_DISTINCT, Token.T_ELSE,
            Token.T_END, Token.T_EVERY, Token.T_EXISTS, Token.T_EXCEPT,
            Token.T_EXTRACT, Token.T_FOR, Token.T_FROM, Token.T_GROUP,
            Token.T_HAVING, Token.T_IF, Token.T_INTO, Token.T_IFNULL,
            Token.T_IS, Token.T_IN, Token.T_INTERSECT, Token.T_JOIN,
            Token.T_INNER, Token.T_LEADING, Token.T_LIKE, Token.T_MAX,
            Token.T_MIN, Token.T_NEXT, Token.T_NULLIF, Token.T_NOT,
            Token.T_NVL, Token.T_MINUS, Token.T_ON, Token.T_ORDER, Token.T_OR,
            Token.T_OUTER, Token.T_POSITION, Token.T_PRIMARY, Token.T_SELECT,
            Token.T_SET, Token.T_SOME, Token.T_STDDEV_POP, Token.T_STDDEV_SAMP,
            Token.T_SUBSTRING, Token.T_SUM, Token.T_THEN, Token.T_TO,
            Token.T_TRAILING, Token.T_TRIM, Token.T_UNIQUE, Token.T_UNION,
            Token.T_VALUES, Token.T_VAR_POP, Token.T_VAR_SAMP, Token.T_WHEN,
            Token.T_WHERE,Token.T_LIMIT,
        };

            for (int i = 0; i < keyword.Length; i++)
            {
                keywords.Add(keyword[i]);
            }
        }

        public static bool isKeyword(string token)
        {
            return keywords.Contains(token);
        }
    }
}
